<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
//    phpinfo();exit;
    return redirect('admin/index');
});

// 登录
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/postlogin', 'Auth\AuthController@login');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

Route::group([
    'middleware' => ['auth'],
    'namespace' => 'Index',
    'prefix' => 'admin'], function () {
     Route::get('index', 'IndexController@index');
});
Route::group([
    'namespace' => 'Admin',
    'prefix' => 'admin'], function () {
    Route::get('kit/captcha/{tmp}', 'CommonController@captcha');
    });



Route::group([
    'middleware' => ['auth','authAdmin'],
    'namespace' => 'Admin',
    'prefix' => 'admin'], function () {

    //权限列表
    Route::get('permission/index', 'PermissionController@index');
    //权限创建
    Route::get('permission/create','PermissionController@create');
    //权限创建 保存
    Route::post('permission/doCreate','PermissionController@doCreate');
    //权限编辑
    Route::get('permission/edit','PermissionController@edit');
    //权限编辑 保存
    Route::post('permission/doEdit','PermissionController@doEdit');
    //权限删除
    Route::post('permission/delete','PermissionController@deleteOnePermission');

    //角色列表
    Route::get('role/index', 'RoleController@index');
    //角色创建
    Route::get('role/create', 'RoleController@create');
    //角色创建 保存
    Route::post('role/doCreate', 'RoleController@doCreate');
    // 角色编辑
    Route::get('role/edit', 'RoleController@edit');
    //角色编辑 保存
    Route::post('role/doEdit', 'RoleController@doEdit');
    //角色删除
    Route::post('role/delete','RoleController@delete');
    //查询角色下所有权限
    Route::get('role/getpermissionsByids','RoleController@getPermissionsByRoles');

    //用户列表
    Route::get('user/index', 'UserController@index');
    //用户创建
    Route::get('user/create', 'UserController@create');
    //用户创建
    Route::post('user/doCreate','UserController@doCreate');
    //用户编辑
    Route::get('user/edit', 'UserController@edit');
    //用户编辑 保存
    Route::post('user/doEdit', 'UserController@doEdit');
    //用户重置密码
    Route::post('user/resetPasswd', 'UserController@resetPasswd');
    //用户删除
    Route::post('user/delete', 'UserController@delete');
    //修改密码
    Route::get('user/modifyPw','UserController@modifyPasswd');
    //用户编辑 保存
    Route::post('user/doModifyPw', 'UserController@doModifyPasswd');

    //栏目列表
    Route::get('category/index','CategoryController@index');
    //栏目 添加
    Route::get('category/create','CategoryController@create');
    //栏目保存 添加
    Route::post('category/doCreate','CategoryController@doCreate');
    //栏目 编辑
    Route::get('category/edit','CategoryController@edit');
    //栏目保存 添加
    Route::post('category/doEdit','CategoryController@doEdit');
    //栏目删除
    Route::post('category/delete','CategoryController@deleteOneCategory');

    //页面元素显示权限
    Route::get('viewItems/index','ViewItemsController@index');
    //页面元素 添加
    Route::get('viewItems/create','ViewItemsController@create');
    //页面元素 保存添加
    Route::post('viewItems/doCreate','ViewItemsController@doCreate');
    //页面元素  编辑
    Route::get('viewItems/edit','ViewItemsController@edit');
    //页面元素  保存编辑
    Route::post('viewItems/doEdit','ViewItemsController@doEdit');
    //页面元素  删除
    Route::post('viewItems/delete','ViewItemsController@delete');
    //页面元素 获取路由下的页面元素
    Route::get('viewItems/getItemsByPermissions','ViewItemsController@getItemsByPermissions');
    //页面元素 获取用户可访问页面元素
    Route::get('viewItems/getItemsByUser','ViewItemsController@getUserCanViewItems');

});

/*Route::group(['namespace' => 'Question', 'middleware' => ['auth']],function(){

    //题库列表
    Route::get('quetions/index','QuestionsController@index');
    //题库 添加
    Route::get('quetions/create','QuestionsController@create');
    //题库 保存添加
    Route::post('quetions/doCreate','QuestionsController@create');


    //资讯类管理
    Route::get('article/index','ArticleController@index');
});*/
Route::group(['middleware' => ['auth']],function(){

    //题库列表
    Route::get('quetions/index','QuestionsController@index');
    //题库 添加
    Route::get('quetions/create','QuestionsController@create');
    //题库 保存添加
    Route::post('quetions/doCreate','QuestionsController@doCreate');
    //题库 删除
    Route::post('quetions/delete','QuestionsController@delete');
    //题库 编辑
    Route::get('quetions/edit','QuestionsController@edit');
    //题库 保存编辑
    Route::post('quetions/doEdit','QuestionsController@doEdit');

    //题库详情 架构师上午添加
    Route::get('quetionsJg/create','QuestionsDetailJGController@create');
    //题库详情 保存添加
    Route::post('quetionsJg/doCreate','QuestionsDetailJGController@doCreate');


    //章节管理
    Route::get('chapter/index','ChapterController@index');
    //章节管理 创建
    Route::get('chapter/create','ChapterController@createNode');
    //章节管理 保存创建
    Route::post('chapter/doCreate','ChapterController@doCreateNode');
    //章节管理 编辑
    Route::get('chapter/edit','ChapterController@edit');
    //章节管理 保存创建
    Route::post('chapter/doEdit','ChapterController@doEdit');
    //章节管理 删除
    Route::post('chapter/delete','ChapterController@delete');

    //章节管理 保存添加
    Route::get('chapter/createRootNode','ChapterController@createRootNode');



    //资讯类管理
    Route::get('article/index','ArticleController@index');


});

Route::group(['namespace' => 'Common','prefix' => 'common','middleware' => ['auth']],function(){
    Route::post('files/upload','UploadController@upload');
    Route::get('files/download/{src_id}','DownloadController@download');
});





Route::group(['namespace' => 'Common','prefix' => 'common','middleware' => ['auth']],function(){
    Route::post('files/upload','UploadController@upload');
    Route::get('files/download/{src_id}','DownloadController@download');
});